import requests
from bs4 import BeautifulSoup

#http://rrkf.com/serv/request?entityCount=347&maxEntityPerPage=10&maxPagePerRow=5&pageCount=35&currentPage=2&currentPageRow=1
# &pageRowCount=7&cBudget=0-1000000000&budgetTo=&statusBy=&categoryBy=&typeBy=&typeName=&orderByClause=a.c_postDate+desc

class CodeMarket:
    def __init__(self):
        self.URL = 'https://www.make8.com/market'
        #self.header = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'}
        self.header = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36' }
        

    def get_project(self):
        #page = str(page)
        #html = requests.get(self.URL, params={'page': page}, headers = self.header)
        #currentPage=1&pageSize=100
        #html = requests.get(self.URL,         params = {"currentPage": "1", "pageSize": "100"}, headers = self.header)
        html = requests.get(self.URL, headers=self.header)

        html.content.decode("utf-8")
        print(html.text)

        soup = BeautifulSoup(html.text, "html.parser")
        #print(soup.get_text())
        for i in range(1,10):
            name = soup.select('#projectView > div:nth-child(6) > div > div.col-xs-12.col-md-12.project-bg > div:nth-child('+str(i)+') > div.col-xs-12.col-md-12.project-name.ng-binding')
            #name = soup.select(' #projectLists > div > ul > li:nth-child(2) > div.left_8 > h4 > a ')
            ##projectView > div:nth-child(6) > div > div.col-xs-12.col-md-12.project-bg > div:nth-child(2) > div.col-xs-12.col-md-12.project-name.ng-binding
            print(name)

if __name__ == "__main__":
    cls = CodeMarket()
    cls.get_project()